#-*-ciding:UTF-8-*-
'''
Copyright (c) [Year] [name of copyright holder]
[Software Name] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
         http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
'''
import os as o
import datetime as dt
import urllib.request as u.r
import error as e

def kill(filename):
	pid=o.getpid(filename)
	o.kill(pid)

def start(filename):
	pid=o.getpid(filename)
	o.start(pid)
	
def cd(path):
	o.chdir(path)
	
def now(presson):
	return dt.now(presson)
	
def new(name,text,close):
	open(name,'w+')
	name.write(text)
	if(close):
		name.close()
	else:
		pass
		
def delete(name):
	o.replase(name)
	
def swap(v1,v2):
	v3=v1
	v2=v1
	v3=v2

def include(mod,pkg):
	if mod==1:
		try:
			o.system('C:/Windows/System32/cmd.exe "python -m pip -i {} https://pypi.tuna.tsinghua.edu.cn/simple/"'.format(pkg))
		except OSError:
			raise e.Syntax_Error("include() function")
	elif mod=2:
		try:
			o.system('C:/Windows/System32/cmd.exe "python -m pip uninstall {}"'.format(pkg))
		except OSError:
			raise e.Syntax_Error("include() function")
		
def about():
	print("/033c",end="")
	print("------------about terminal------------- /n Terminal 0.0.1 by Windowsjiang /n (C) 2024 Windowsjiang")
	
def now(presson):
	try:
		return dt.datetime.now(presson)
	except:
		raise e.Syntax_Error("now() function")